//
//  BMCycleImage.m
//  LBFZ-ML
//
//  Created by GivenBmli on 16/8/6.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "BMCycleImage.h"
#define kCollectionViewCellRetun @"retun"
#define kCollectionSjColor [UIColor colorWithRed:arc4random() % 256 / 255.0f green:arc4random() % 256 / 255.0f blue:arc4random() % 256 / 255.0f alpha:1];
@interface BMCycleImage ()<UICollectionViewDelegate , UICollectionViewDataSource>
@property (nonatomic , strong)UICollectionViewFlowLayout *flowLayout;
@property (nonatomic , strong)UICollectionView *cycleCollectionView;
@property (nonatomic , strong)UIPageControl *pageControl;

@end

@implementation BMCycleImage
- (instancetype)initWithFrame:(CGRect)frame {
    self =[super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor redColor];
    }
    return self;
}

- (void)setUp {
    [self creatCollectionView];
//    [self ]
}


- (void)creatCollectionView {
    _flowLayout = [[UICollectionViewFlowLayout alloc]init];
    _flowLayout.minimumLineSpacing = 0;
    _flowLayout.minimumInteritemSpacing = 0;
    _flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    _cycleCollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:_flowLayout];
    _cycleCollectionView.pagingEnabled = YES;
    _cycleCollectionView.delegate = self;
    _cycleCollectionView.dataSource = self;
    [_cycleCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:kCollectionViewCellRetun];
    [self addSubview:_cycleCollectionView];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionViewCellRetun forIndexPath:indexPath];
    cell.contentView.backgroundColor = kCollectionSjColor;
    return cell;
}

@end
